<template>
  <div class="home">
    <el-container class="out">
      <el-aside width="240px">
        <div class="logo">
          <p>帮助文档管理系统</p>
        </div>
        <el-menu
            :unique-opened=true
            :default-active="$route.path"
            class="el-menu-vertical"
            router
            background-color="rgba(0,0,0,0)"
            text-color="#fff"
            active-text-color="#2A7AFF">

    

          <el-submenu index="4">
            <template slot="title">
              <i class="el-icon-edit-outline"></i>
              <span>文档编写</span>
            </template>
            <!-- <el-menu-item-group>
              <el-menu-item index="/all/configMenu">
                <i class="el-icon-setting"></i>
                <span>配置左侧菜单</span>
              </el-menu-item>
            </el-menu-item-group> -->
            <el-menu-item-group>
              <el-menu-item index="/all/usersmanual">
                <i class="el-icon-setting"></i>
                <span>帮助文档管理</span>
              </el-menu-item>
            </el-menu-item-group>
            <el-menu-item-group>
              <el-menu-item index="/all/markdown">
                <i class="el-icon-setting"></i>
                <span>MD模板管理</span>
              </el-menu-item>
            </el-menu-item-group>
          </el-submenu>


       


        </el-menu>
      </el-aside>
      <el-container class="main">
        <headerMain :showTitle="false"></headerMain>
        <el-main>
          <router-view />
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import { getMenu } from '@/api/user'
import headerMain from "../components/headerMain";

export default {
  name: "Home",
  data() {
    return {
      name: "",
      resourceIds: []
    };
  },
  components: { headerMain },
  created() {
    this.getUserMenu()
    this.$router.replace({
      name: "general",
    });
  },
  methods: {
    // 获取用户菜单
    getUserMenu () {
      getMenu({ sysCode: process.env.VUE_APP_SYS_CODE }).then(response => {
        this.resourceIds = response.data
      })
    },
    // 判断哪个菜单显示
    isActive (menu) {
      this.active = false
      var flag = false
      for (var i in this.resourceIds) {
        if (this.resourceIds[i] === menu) {
          flag = true
          break
        }
      }
      return flag
    },
    logout() {
      window.close()
    }
  },
};
</script>

<style lang="less" scoped>
.out {
  height: 100%;
  .el-aside {
    background: linear-gradient(180deg, #131c26 0%, #152f57 66%, #0e3c83 100%);
    font-size: 14px;
    position: fixed;
    z-index: 22;
    height: 100%;
    .logo {
      display: flex;
      align-items: center;
      cursor: pointer;
      justify-content: center;
      border-bottom: 1px solid #000000;
      img {
        width: 26px;
        height: 26px;
        margin-right: 10px;
      }
      p {
        font-size: 16px;
        color: #ffffff;
        height: 78px;
        line-height: 78px;
        text-align: center;
        letter-spacing: 3px;
      }
    }
    .select {
      width: 100%;
      text-align: center;
      position: relative;
      margin: 26px 0;
      > i {
        position: absolute;
        top: 13.5px;
        left: 34px;
        color: rgba(255, 255, 255, 0.5);
        z-index: 1;
        font-size: 13px;
      }
      /deep/.el-select {
        width: 200px;
        border-radius: 5px;
        .el-input__inner {
          background: #3480ff;
          border: none;
          color: #fff;
          padding-left: 40px;
        }
      }
    }
    .el-menu {
      width: 240px;
      border-right: none;
      .el-menu-item {
        &.is-active {
          background-color: #111111 !important;
          &> i{
            color:rgb(42, 122, 255)
          }
          &> span{
            color:rgb(42, 122, 255)
          }
        }
        &:hover {
          background-color: #111111 !important;
          &> i{
            color:rgb(42, 122, 255)
          }
          &> span{
            color:rgb(42, 122, 255)
          }
        }
      }
    }
    li {
      font-size: 14px;
      padding-left: 30px;
      width: 240px;
      i {
        color: rgba(107, 124, 167, 1);
        margin-right: 10px;
        font-size: 20px;
      }
      &.is-active {
        .el-submenu__title i {
          color: rgb(42, 122, 255);
        }
        .el-submenu__title span {
          color: rgb(42, 122, 255);
        }
      }
      &:hover {
        .el-submenu__title i {
          color: rgb(42, 122, 255);
        }
        .el-submenu__title span {
          color: rgb(42, 122, 255);
        }
      }
    }
    .el-menu-item-group {
      padding-left: 0px !important;
      background-color: #111111 !important;
      ul {
        li {
          padding-left: 49px !important;
          border-bottom: 1px solid rgb(0, 0, 0, 0.34);
          &:first-child {
            margin-top: -14px;
          }
        }
      }
    }
    li.el-submenu {
      font-size: 14px;
      padding-left: 30px;
      width: 240px;
      i {
        color: rgba(107, 124, 167, 1);
        margin-right: 10px;
        font-size: 20px;
      }
      //&.is-active {
      //  i,
      //  span {
      //    color: rgb(42, 122, 255);
      //  }
      //}
      &:nth-child(1) {
        padding-left: 0px !important;
        /deep/.el-submenu__title:hover,
        /deep/.el-submenu__title.is-active {
          color: rgb(42, 122, 255);
          background-color: #111111 !important;
        }
      }
      &:nth-child(2) {
        padding-left: 0px !important;
        /deep/.el-submenu__title:hover,
        /deep/.el-submenu__title.is-active {
          color: rgb(42, 122, 255);
          background-color: #111111 !important;
        }
      }
      &:nth-child(3) {
        padding-left: 0px !important;
        /deep/.el-submenu__title:hover,
        /deep/.el-submenu__title.is-active {
          color: rgb(42, 122, 255);
          background-color: #111111 !important;
        }
      }
      &:nth-child(4) {
        padding-left: 0px !important;
        /deep/.el-submenu__title:hover,
        /deep/.el-submenu__title.is-active {
          color: rgb(42, 122, 255);
          background-color: #111111 !important;
        }
      }
      &:nth-child(5) {
        padding-left: 0px !important;
        /deep/.el-submenu__title:hover,
        /deep/.el-submenu__title.is-active {
          color: rgb(42, 122, 255);
          background-color: #111111 !important;
        }
      }
      &:nth-child(6) {
        padding-left: 0px !important;
        /deep/.el-submenu__title:hover,
        /deep/.el-submenu__title.is-active {
          color: rgb(42, 122, 255);
          background-color: #111111 !important;
        }
      }
      &:nth-child(7) {
        padding-left: 0px !important;
        /deep/.el-submenu__title:hover,
        /deep/.el-submenu__title.is-active {
          color: rgb(42, 122, 255);
          background-color: #111111 !important;
        }
      }
      &:nth-child(8) {
        padding-left: 0px !important;
        /deep/.el-submenu__title:hover,
        /deep/.el-submenu__title.is-active {
          color: rgb(42, 122, 255);
          background-color: #111111 !important;
        }
      }
    }
  }
}
.main {
  overflow-y: scroll;
  background:#FFF;
  .el-header {
    box-shadow: 0px 0px 13px rgba(32, 47, 79, 0.09);
    height: 78px;
    background: #fff;
    padding: 0 25px;
    display: flex;
    align-items: center;
    justify-content: flex-end; // width: calc( 100% - 230px);
    width: 100%;
    position: fixed;
    z-index: 10;
    .right {
      display: flex;
      align-items: center;
      img {
        cursor: pointer;
        width: 37px;
        margin-right: 20px;
        &:not(:first-of-type) {
          width: 30px;
          height: 30px;
        }
      }
      .el-badge {
        margin-right: 20px;
        img {
          width: 30px;
          height: 30px;
          cursor: pointer;
          margin: 0;
        }
      }
      p {
        line-height: 27px;
        color: #445a5a;
        margin-right: 20px;
      }
    }
  }
  .el-main {
    padding: 0px;
    // background: #fff;
    overflow: initial;
    margin-top: 60px;
    margin-left: 240px;
    height: calc(100% - 60px);
    width:calc(100% - 240px)
  }
  @media screen and (max-width: 1440px) {
    .el-main {
      width:100%
    }
  }
}
</style>


